<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commons/global.jsp" %>
<!DOCTYPE html>
<html>
<head>
<%@ include file="/commons/basejs.jsp" %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>主页</title>
<script type="text/javascript">

    function submit() {
        var m = $('#method').val();
        var u = $('#url').val();
        var d = $('#data').val();
        console.log("m:"+m);
        console.log("u:"+u);
        console.log("d:"+d);
        if (m == 'GET'){
            $.get(u,d,function (data) {
                $('#value').val(data);
            });
        }else if(m == 'POST') {
            $.post(u,d,function (data) {
                $('#value').val(data);
             });
        }


    }
</script>

</head>
<body>
<div>
    请求方式:
    <br/><select id="method">
        <option value="GET">GET</option>
        <option value="POST">POST</option>
    </select>
    <br/>
    <br/>
    url:
    <br/><textarea id="url" style="width:52%;height: 70px"></textarea>
    <br/>
    <br/>
    data:
    <br/><textarea id="data" style="width:52%;height: 70px"></textarea>
    <br/>

    <div style="margin-top: 20px;text-align: center">
        <input type="button" onclick="submit()" value="submit" >
    </div>
</div>
<div>
    <br/>
    result:
    <br/>
    <textarea id="value" style="width:100%;height: 200px"></textarea>
</div>
</body>
</html>